<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<link rel="stylesheet" href="css/bootstrap.css">
	<script src="js/jquery.min.js"></script>
	<script src="js/bootstrap.js"></script>
</head>
<body>
	<h1>tp，api测试</h1>
	<!-- 819648983 -->
	新闻<br>
	<button type="button" class="btn btn-primary">查询</button><br>
	<button type="button" class="btn btn-primary">添加</button><br>
	<button type="button" class="btn btn-primary">删除</button><br>
	<button type="button" class="btn btn-primary">修改</button><br>
	<script>
	$(function(){
		$(".btn").on("click",function(){
			var v=$(this).text();
			switch(v)
			{
				case "添加":
					/* 添加文章到数据表 news */
					$.ajax({
					    url: "http://localhost/DAdmin/DAdmin/public/index.php/news",
					    method: "POST",
					    data: {"title": "标题", "content":"文章内容"},
					    success: function(rsp){ console.log(rsp)}
					});
					break;
				case "查询":
					/* 查询文章数据表 news */
					$.ajax({
					    url: "http://localhost/DAdmin/DAdmin/public/index.php/news/1",
					    method: "GET",
					    // data: {"title": "标题", "content":"文章内容"},
					    success: function(rsp){ console.log(rsp)}
					});
					break;
				case "删除":
					/* 删除数据表 news 中的数据 */
					$.ajax({
					    url: "http://localhost/DAdmin/DAdmin/public/index.php/news/1",
					    method: "DELETE",
					    // data: {"cart_id": "123", "goods_id":"goods_123"},
					    success: function(rsp){ console.log(rsp)}
					});
				  
					break;
				case "修改":
					/* 修改数据表 news 中的 数据*/
					$.ajax({
					    url: "http://localhost/DAdmin/DAdmin/public/index.php/news/4",
					    method: "PUT",
					    data: {"title": "123", "content":"新的文章"},
					    success: function(rsp){ console.log(rsp)}
					});
					break;
			}
		});


	})
	</script>
</body>
</html>